package com.wenhao.minglue;

import java.util.*;


public class Main2 {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param prices int整型一维数组 the stock price list.
     * @return int整型
     */
    public int MaxProfit (int[] prices) {
        // write code here
        int profit = 0;
        int min = prices[0];
        for (int i = 1;i < prices.length;i++) {
            if (prices[i] < min) {
                min = prices[i];
            }else {
                profit = Math.max(profit,prices[i] - min);
            }
        }
        return profit;
    }
}
